import { RenderRoot2D, game } from "cc"
import { EnemyManager } from "../Base/EnemyManager"
import SingLeton from "../Base/SingLeton"
import { DEFAULT_DURATION, DrawManager } from "../Script/UI/DrawManager"
import { WoodenSkeletonManage } from "../Script/WoodenSkeleton/WoodenSkeletonManage"
import { createUINode } from "../Utils"

export default class FaderManager extends SingLeton {


    static get Instance() {
        return super.GetInstance<FaderManager>(

        )
    }


    private _fader: DrawManager = null


    get fader(): DrawManager {
        if (this._fader !== null) {

            return this._fader
        }

        const root = createUINode()
        root.addComponent(RenderRoot2D)



        const fader = createUINode()
        fader.setParent(root)
        this._fader = fader.addComponent(DrawManager)
        this._fader.init()


        game.addPersistRootNode(root)

        return this._fader
    }


    fadeIn(duration:number=DEFAULT_DURATION) {
        return this.fader.fadeIn(duration)

    }


    fadeOut(duration:number=DEFAULT_DURATION) {

        return this.fader.fadeOut(duration)

    }
}








// export const DataManagerInstance = new DataManager()  //暴露一个实例
